﻿using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace TopShooter
{
	public class KeyPressEvent
	{
		public bool RequireCtrl;
		public bool OnlyOnce;
		public Keys Key;
		public Action<Keys> Action;
		public bool IsKeyDown = false;
		public bool EnableRepeat;
		public int TimeForNextRepeat;
	}

	[Flags]
	public enum KeyboardModes
	{
		Normal = 0,
		Shift = 1,
		Ctrl = 2,
		Alt = 4
	}

	public struct MouseButtonState
	{
		public MouseButtons Buttons;
		public bool IsLeftMouseDown { get { return (Buttons & MouseButtons.Left) != 0; } }
		public bool IsMiddleMouseDown { get { return (Buttons & MouseButtons.Middle) != 0; } }
		public bool IsRightMouseDown { get { return (Buttons & MouseButtons.Right) != 0; } }

		public MouseButtonState(MouseButtons btns)
		{
			Buttons = btns;
		}
	}


	[Flags]
	public enum MouseButtons
	{
		None = 0,
		Left = 1,
		Right = 2,
		Middle = 4
	}

	[Flags]
	public enum MouseEventTypes
	{
		None = 0,
		ButtonDown = 1,
		ButtonUp = 2,
		ButtonClick = 4,
		Move = 8,
		Drag = 16,
		WheelChanged = 32,
		ButtonDoubleClick = 64
	}

	public class MouseEvent
	{
		public MouseEventTypes TypesActivated;
		public MouseButtons ButtonsActivated;

		public Action<MouseEvent> Action;
		public MouseEventTypes Types;
		public MouseButtons Buttons;
		public KeyboardModes KeyboardMode;

		public Point StartEventLocation;

		public bool IsButtonClick { get { return (Types & MouseEventTypes.ButtonClick) != 0; } }
		public bool IsButtonDown { get { return (Types & MouseEventTypes.ButtonDown) != 0; } }
		public bool IsButtonUp { get { return (Types & MouseEventTypes.ButtonUp) != 0; } }
		public bool IsDrag { get { return (Types & MouseEventTypes.Drag) != 0; } }
		public bool IsMove { get { return (Types & MouseEventTypes.Move) != 0; } }
		public bool IsWheelChanged { get { return (Types & MouseEventTypes.WheelChanged) != 0; } }

		public bool IsLeftButton { get { return (Buttons & MouseButtons.Left) != 0; } }
		public bool IsMiddleButton { get { return (Buttons & MouseButtons.Middle) != 0; } }
		public bool IsRightButton { get { return (Buttons & MouseButtons.Right) != 0; } }

		public Point ScreenLocation;
		public Point AbsoluteLocation;
		public Coordinate MapCoordinate;

		public bool WasLeftClick;
		public bool WasRightClick;
		public bool WasMiddleClick;
		public int WheelDelta;
	}
}
